#include <stdio.h>
#include <string.h>

char tu[1010][1010];
// 1 for quenen, 2 for K, 3 for block , 0 for free
// -1 for attack
int  pos[3][200][2];
int  num[3];
int  n, m;
int  ncase=0;

int  movex[]={1,-1,0,0 ,  1,1,-1,-1};
int  movey[]={0,0, 1,-1,  1,-1,1,-1};
int  horsex[]={1,1,-1,-1,2,-2,2,-2};
int  horsey[]={2,-2,2,-2,1,1,-1,-1};

void mark1()
{
	int i, j, x, y, tox, toy;
	for (i=1; i<=num[0]; ++i)
	{
		x = pos[0][i][0];
		y = pos[0][i][1];
		for (j=0; j<8; ++j)
		{
			tox = x+movex[j];
			toy = y+movey[j];
			while ((tu[tox][toy]==0 || tu[tox][toy]==-1) && tox>=1 && tox<=n && toy>=1 && toy<=m)
			{
				tu[tox][toy] = -1;
				tox = tox+movex[j];
				toy = toy+movey[j];
			}
		}
	}
}

void mark2()
{
	int i, j, x, y, tox, toy;
	for (i=1; i<=num[1]; ++i)
	{
		x = pos[1][i][0];
		y = pos[1][i][1];
		for (j=0; j<8; ++j)
		{
			tox = x+horsex[j];
			toy = y+horsey[j];
			while (tu[tox][toy]==0 && tox>=1 && tox<=n && toy>=1 && toy<=m)
			{
				tu[tox][toy] = -1;
			}
		}
	}
}

void output()
{
	int i, j;
	printf("tu:\n");
	for (i=1; i<=n; ++i, printf("\n") )
		for (j=1; j<=m; ++j)
		{
			printf("%2d", tu[i][j]);
		}
	printf("\n");
}

bool in()
{
	int i, j;
	scanf("%d%d", &n, &m); 
	memset(tu, 0, sizeof(tu));
	if (n==0 && m==0) return false;
	for (i=0; i<3; ++i)
	{
		scanf("%d", &num[i]);
		for (j=1; j<=num[i]; ++j)
		{
			scanf("%d%d", &pos[i][j][0], &pos[i][j][1]);
			tu[pos[i][j][0]][pos[i][j][1]] = i+1;
		}
	}
	return true;
}

void deal()
{
	mark1();
	//output();
	mark2();
	//output();
}

void outans()
{
	int i, j;
	int ans=0;
	for (i=1; i<=n; ++i)
		for (j=1; j<=m; ++j)
			if (tu[i][j]==0) ans++;
	//printf("ans=%d\n", ans);
	printf("Board %d has %d safe squares.\n", ++ncase, ans);


}

int main()
{
	while (in())
	{
		deal();
		outans();
	}
			

	return 0;
}
